package ExamLab.Test3;

public class ThreadClass extends Thread {

	public ThreadClass(int x) {
		this.x = x;
	}

	static String s = "";
	static volatile int x = 0;

	public static void doVIP() {
		s = s + x;
		try {
			Thread.sleep(10);
		} catch (Exception e) {
			s = s + x;
		}
	}

	public void run() {
		synchronized (s) {
			doVIP();
		}
	}

	public static void doDelay(long g) {
		try {
			Thread.sleep(g);
		} catch (Exception e) {
		}
	}

	public static void main(String args[]) {

		ThreadClass tc1 = new ThreadClass(2);
		ThreadClass tc2 = new ThreadClass(1);
		ThreadClass tc3 = new ThreadClass(0);

		tc1.start();
		doDelay(100);
		System.out.print(s);
		tc2.start();
		doDelay(100);
		System.out.print(s);
		tc3.start();
		doDelay(100);
		System.out.print(s);

	}
}